﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bzure.Mvc
{
    /// <summary>
    ///可加载程序块
    /// </summary>
    public class AppSection
    {
        public AppSection()
        {
            this.SectionName = string.Empty;
            this.Title = string.Empty;
            this.Description = string.Empty;
            this.LogoUrl = string.Empty;
            this.Groups = default(string[]);
            this.Index = 0;
        }
        /// <summary>
        /// 程序块唯一名称
        /// </summary>
        public string SectionName { get; set; }
        /// <summary>
        /// 程序块主题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 程序块描述
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 程序块Logo地址
        /// </summary>
        public string LogoUrl { get; set; }
        /// <summary>
        /// 获取块的首页地址
        /// </summary>
        public Func<string> GetHomeUrl { get; set; }
        /// <summary>
        /// 是否允许加载程序块
        /// </summary>
        public Func<bool> AllowLoad { get; set; }
        /// <summary>
        ///程序块组
        /// </summary>
        public string[] Groups { get; set; }
        /// <summary>
        /// 排列顺序
        /// </summary>
        public int Index { get; set; }
        /// <summary>
        /// 获取菜单项
        /// </summary>
        public Func<AppMenuItem[]> GetMenus { get; set; }
        public override bool Equals(object obj)
        {
            if (obj is AppSection)
            {
                AppSection area = obj as AppSection;
                return area.SectionName.Equals(this.SectionName, StringComparison.OrdinalIgnoreCase);
            }
            return base.Equals(obj);
        }
        public override int GetHashCode()
        {
            return this.SectionName.GetHashCode();
        }
    }

    public class AppMenuItem
    {
        /// <summary>
        /// 菜单名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 菜单地址
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 菜单描述
        /// </summary>
        public string Tip { get; set; }
        /// <summary>
        /// 菜单标示
        /// </summary>
        public string MenuFlag { get; set; }
        /// <summary>
        /// 获取菜单项
        /// </summary>
        public Func<AppMenuItem[]> GetMenus { get; set; }
        public AppMenuItem()
        {
        }
    }
}
